import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
import persistence.Installer;
import persistence.TweetListenerService;
import view.BioscoopAdministratieUI;

public class BioscoopAdministratie {

  public static void main(String[] args) {
        Installer.install();

        try {
              // Create ActiveMQ Connection Factory
              ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover://(tcp://localhost:61616,tcp://localhost:61617)?randomize=false");

              // Create a Connection to ActiceMQ
              Connection connection = connectionFactory.createConnection();
              connection.start();

              // Create a Session that allows you to work with activeMQ
              Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

              // Create the destination queue (or retrieve it, if it already exists)
              Destination queue = session.createQueue("TWITTER.QUEUE");
              MessageConsumer consumer = session.createConsumer(queue);

              TweetListenerService listener = new TweetListenerService();
              consumer.setMessageListener(listener);

          }
          catch (JMSException ex) {
              System.out.println(ex.getMessage());
          }

        new BioscoopAdministratieUI();
  }
}
